home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / s342q08.lha / liblog.c < prev    next >
C/C++ Source or Header  |  1993-06-18  |  2KB  |  88 lines

  1. /*
  2. *                liblog.c
  3. *
  4. * Citadel log code for the library.
  5. */
  6. /*
  7. *                history
  8. *
  9. * 85Nov15 HAW  File created.
  10. */
  11. #include "ctdl.h"
  12. /*
  13. *                contents
  14. *
  15. *    getLog()        loads requested CTDLLOG record
  16. *    putLog()        stores a logBuffer into citadel.log
  17. */
  18. logBuffer logBuf;        /* Log buffer of a person       */
  19. logBuffer logTmp;        /* Useful global buffer        */
  20. int       thisLog;        /* entry currently in logBuf    */
  21. FILE      *logfl;        /* log file descriptor        */
  22. extern CONFIG cfg;        /* Configuration variables      */
  23. /*
  24. * getLog()
  25. *
  26. * This loads requested log record into the specified RAM buffer.
  27. */
  28. void getLog(logBuffer *lBuf, int n)
  29.   {
  30.   long int s, r;
  31.   if (lBuf == &logBuf)   thisLog      = n;
  32.   r = LB_TOTAL_SIZE;        /* To get away from overflows   */
  33.   s = n * r;            /* This should be offset    */
  34.   n *= 3;
  35.   if (cfg.weAre != CONFIGUR)
  36.   fseek(logfl, s, 0);
  37.   if (fread(lBuf, LB_SIZE, 1, logfl) != 1) 
  38.     {
  39.     crashout("?getLog-read fail//EOF detected (1)!");
  40.     
  41.     }
  42.   crypte(lBuf, LB_SIZE, n);    /* decode buffer    */
  43.   if (fread(lBuf->lbgen, GEN_BULK, 1, logfl) != 1) 
  44.     {
  45.     crashout("?getLog-read fail//EOF detected (2)!");
  46.     
  47.     }
  48.   if (fread(lBuf->lbMail, MAIL_BULK, 1, logfl) != 1) 
  49.     {
  50.     crashout("?getLog-read fail//EOF detected (3)!");
  51.     
  52.     }
  53.   
  54.   }
  55. /*
  56. * putLog()
  57. *
  58. * This function stores the given log record into ctdllog.sys.
  59. */
  60. void putLog(logBuffer *lBuf, int n)
  61.   {
  62.   long int s, r;
  63.   r = LB_TOTAL_SIZE;
  64.   s = n * r;
  65.   n   *= 3;
  66.   crypte(lBuf, LB_SIZE, n);        /* encode buffer    */
  67.   if (cfg.weAre != CONFIGUR)        /* No need if configuring    */
  68.   fseek(logfl, s, 0);
  69.   if (fwrite(lBuf, LB_SIZE, 1, logfl) != 1) 
  70.     {
  71.     crashout("?putLog-write fail (1)!");
  72.     
  73.     }
  74.   if (fwrite(lBuf->lbgen, GEN_BULK, 1, logfl) != 1) 
  75.     {
  76.     crashout("?putLog-write fail (2)!");
  77.     
  78.     }
  79.   if (fwrite(lBuf->lbMail, MAIL_BULK, 1, logfl) != 1) 
  80.     {
  81.     crashout("?putLog-write fail (3)!");
  82.     
  83.     }
  84.   crypte(lBuf, LB_SIZE, n);    /* encode buffer    */
  85.   fflush(logfl);
  86.   
  87.   }
  88.